package com.raul.prueba.WSBlackjack;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.raul.prueba.WSBlackjack.vo.VOLogin;

/**
 * Servlet implementation class LoginServlet
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String usuario = request.getParameter("usuario");
        String password = request.getParameter("password");
        if (!usuario.equals("Yeho") || !password.equals("123")){
                response.sendRedirect("login.html");
                return;
        } else {
                VOLogin vo = new VOLogin();
                vo.setUsuario(usuario);
                vo.setPassword(password);
                HttpSession session= request.getSession(true);
                List<VOLogin> lista1 = new ArrayList<VOLogin>();
                session.setAttribute("UsuarioLogeado", vo);
                session.setAttribute("Listajugadores", lista1);
                request.getRequestDispatcher("inicio.jsp").forward(request, response);
        }
        
}

}